<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%cms_token}}".
 *
 * @property string $id
 * @property string $uid
 * @property string $token
 * @property integer $create_time
 * @property string $token_time
 * @property string $refresh_token
 * @property string $taobao_user_nick
 * @property string $taobao_user_id
 * @property string $pid
 * @property string $qq_pid
 * @property integer $is_enable
 * @property integer $is_notice
 * @property integer $source
 */
class QtkCmsToken extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%cms_token}}';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('qtk');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'create_time', 'taobao_user_id', 'is_enable', 'is_notice', 'source'], 'integer'],
            [['token_time'], 'safe'],
            [['token', 'refresh_token', 'taobao_user_nick'], 'string', 'max' => 100],
            [['pid', 'qq_pid'], 'string', 'max' => 50],
            [['uid', 'taobao_user_id', 'source'], 'unique', 'targetAttribute' => ['uid', 'taobao_user_id', 'source'], 'message' => 'The combination of 用户id, 淘宝id and 1：轻淘客官网；2：CMS工具 has already been taken.'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '自增id',
            'uid' => '用户id',
            'token' => '授权码',
            'create_time' => '创建时间',
            'token_time' => '授权码时间',
            'refresh_token' => '刷新授权码',
            'taobao_user_nick' => '淘宝账号昵称',
            'taobao_user_id' => '淘宝id',
            'pid' => '用户的微信的PID',
            'qq_pid' => '用户的QQ的PID',
            'is_enable' => '是否启用,0未启用，1启用',
            'is_notice' => '是否提醒安装插件,0不提醒，1提醒',
            'source' => '1：轻淘客官网；2：CMS工具',
        ];
    }
}
